package graphic.primitives.car;

import graphic.primitives.general.GraphicObject;
import graphic.primitives.general.IGraphicObject;

public class Light extends GraphicObject implements IGraphicObject{

	private boolean sviti;
	private int sirka;
	
	public Light(int x, int y, int sirka) {
	super(x, y);
	this.sirka = sirka;
	}
	
	@Override
	public void redraw() {
		mainWindow.line(x+sirka, y, x+sirka, y+sirka);
		mainWindow.line(x, y+sirka/3, x+sirka, y);
		mainWindow.line(x, y+sirka/3, x, y+sirka/3*2);
		mainWindow.line(x, y+sirka/3*2, x+sirka, y+sirka);
		
		if(jeRozviceno()){
			mainWindow.line(x+sirka, y+sirka/3, x+2*sirka, y);
			mainWindow.line(x+sirka, y+sirka/2, x+2*sirka, y+sirka/2);
			mainWindow.line(x+sirka, y+2*(sirka/3), x+2*sirka, y+sirka);
		}
	}
	
	public boolean jeRozviceno(){
		if(sviti==true) return true;
		else return false;
	}
	public void prepniSvetlo() {
		if(jeRozviceno()) zhasni();
		else rozsvit();
	}
	public void rozsvit() {
		sviti = true;
	}
	public void zhasni() {
		sviti = false;
	}
}
